#include<stdio.h>
int main(){
	char a[100]={"\0"},b[100]={"\0"},ans[100]={"\0"};
	int d[100][100]={0},i,j;
	scanf("%s",a+1);
	getchar();
	scanf("%s",b+1);
	for(i=1;a[i]!='\0';i++)
		for(j=1;b[j]!='\0';j++){
			if(a[i]==b[j])
				d[i][j]=d[i-1][j-1]+1;
			else
				d[i][j]=d[i][j-1]>d[i-1][j]?d[i][j-1]:d[i-1][j];
		}
	i--;j--;
	int len=d[i][j];
	while(i>0&&j>0){
		if(d[i][j]==d[i-1][j])
			i--;
		else if(d[i][j]==d[i][j-1])
			j--;
		else ans[len--]=a[i--],j--;
	}
	printf("%s\n",ans+1);
} 
